{include file=header.html}
 <script type="text/javascript" language="javascript" src="{lib file=jquery-1.6.3.min.js}"></script>
<script language="javascript" type="text/javascript" src="{lib file=jquery.ui/jquery.ui.js}"></script>
<script language="javascript" type="text/javascript" src="{res file=DatePicker/WdatePicker.js}"></script>
<script language="javascript" type="text/javascript" src="{res file=js/fabric_info.js}"></script>
<script language="javascript" type="text/javascript" src="{res file=js/jquery.funkyUI.js}"></script>
<script language="javascript" type="text/javascript" src="{res file=js/common.js}"></script>
<script language="javascript" type="text/javascript" src="{lib file=jquery.plugins/jquery.validate_1.11.0.js}"></script>
<script language="javascript" type="text/javascript" src="{res file=js/select.js}"></script>
<style type="text/css">
.btn-2{margin-bottom:5px;}
.table_no_border,.table_no_border td,.table_no_border th{
	padding:0;
	margin:0;
	border-width:0 1px 0 0;
	}
.fabric_info_list td input,.fabric_info_list td select{width:93%;}
.fabric_info_table td,.fabric_info_table th{
	border-left:none;
	border-bottom:none;
	}
.fabric_info_table th
{
   border-top:none;
}
.tab-display .no_right_border
{
	border-right:none;
}
.fabric_info_table .btn-2{
	line-height:20px;
	height:20px;
	margin-bottom:1px;}
#sample_filesize {width:100px;word-wrap: break-word;word-break: normal;word-break:break-all;}
</style>
<script type="text/javascript">
$(function() {
	$('select[select_input="select_input"]').each(function(i) {
		init_select_input($(this));
	});
	$('div.select-input').each(function(i) {
		$(this).css('z-index', $('div.select-input').length - i);
	});
	$('#add_fabric_info').click(function() {
		var tr = $('<tr><th align="right">{$lang.desc}：</th><td class="tab-align-l" colspan="3"></td><th align="right">{$lang.fabric_shop_name}：</th><td class="tab-align-l" colspan="3"></td><td colspan="2" align="left"></td></tr>');
		var sel_input = $($('#fabric_shop_data').html());
		sel_input.attr('select_input', 'select_input');
		sel_input.attr('name', 'new_fabric_info[][fabric_shop_id]');
		sel_input.attr('id', 'new_fabric_info[][fabric_shop_id]');
		sel_input.attr('class', 'input-3');
		var desc = $('<input type="text" class="input-3" name="new_fabric_info[][description]">');
		tr.find('td:eq(0)').append(desc);
		tr.find('td:eq(1)').append(init_select_input(sel_input));
		$('div.select-input').each(function(i) {
			$(this).css('z-index', $('div.select-input').length - i);
		});
		tr.css('background-color', '#F4F8FA');
		var add_fabric_shop = $('#add_fabric_shop');
		tr.insertAfter(add_fabric_shop.parents('tr'));
		if ($('input.btn-2[value="移除"]').length < 1) {
			add_fabric_shop.parent().append($('<input type="button" value="移除" class="btn-2" />'));
		}
		tr.find('td:eq(2)').append($('<input type="button" value="移除" class="btn-2" />'));
		tr.find('td:eq(2)').append(add_fabric_shop);
	//	$('input.btn-2[value="移除"]').click(function() {
	//		remove_fabric_shop($(this));
	//	});
		sort_new_fabric_info();
	});

	$('input[acttype="confirm"]').click(function() {
		if (confirm('是否已经保存信息？更新样板信息之后将会使已确认样板状态无效。\r\n\r\n是否继续？')) {
			$.getJSON('index.php?app=sample&act=confirm&id={$smarty.get.id}', function(json) {
				alert(json.msg);
			});
		}
	});
	
});

function sort_new_fabric_info()
{
	$('input[name^="new_fabric_info"][name$="[description]"]').each(function(i) {
		$(this).attr('name', 'new_fabric_info[' + i + '][description]');
	});
	$('input[name^="new_fabric_info"][name$="[fabric_shop_id]"]').each(function(i) {
		$(this).attr('name', 'new_fabric_info[' + i + '][fabric_shop_id]');
		$(this).attr('id', 'new_fabric_info[' + i + '][fabric_shop_id]');
	});
}

function remove_fabric_shop(_this)
{
	if (!confirm('确定要移除该面料信息吗？')) {
		return;
	}
	$(_this).parent().parent().remove();
}


function check_factory_submit(){

	if(confirm('请仔细检查填写内容是否正确，确认是否提交？')==true){
		var ml_num=0;
		$(".fabric_info_list").each(function(){
				
			if($(this).find("[item='fabric_shop_name']").val()!=0 && $(this).find("[item='item']").val()!=0 && $(this).find("[item='fabric_characteristics']").val()!="")
			{
				ml_num++;
			}
		});
		
		if(ml_num==0)
		{
			alert("请输入面料信息");
			return false;
		}
		
		
	}
	
	return true;
}

function approve_no()
{
	
	if($("#approve_no_desc").val()=="")
	{
		$.funkyUI({url:"index.php?app=purchase&act=approve_not_pass",css:{width:"455",height:"330"}});
		return false;
	}
	return true;
}

function re_factory()
{
	
	if($("#return_factory_desc").val()=="")
	{
		
		$.funkyUI({url:"index.php?app=sample&act=return_factory",css:{width:"455",height:"330"}});
		return false;
	}
	return true;
}

function s_dayin(){
	if(confirm('确定要打印此采购单吗?打印此采购单后将不能再更改！')!=true){
		return false;
	}else{
		window.open('{$site_url}/index.php?app=purchase&act=print_bulk&id={$smarty.get.id}');
	}
}
</script>
<body>
<div class="sub-body">
      
  <div class="tab-frame" style="width:1050px;">
  <h3 class="tab-title-1"><span>{$lang.order_sour_info}</span></h3>
		<form method="post" id="sour_form" action="{url app=purchase&act=$smarty.get.act&id=$smarty.get.id}">
    <table width="100%" cellspacing="0" cellpadding="0" class="tab-display">
    	<tr>
          	<th  align="right" width="120">下单日期：</th>
          	<td width="180">{$sours.order_create_date|date}&nbsp;&nbsp;状态：{$lang.order_status.$sours.status}</td>
          	<th colspan="2" width="300">正面</th>
          	<th colspan="2" width="300">反面</th>
        </tr>
		<tr>
           	<th  align="right">品&nbsp;&nbsp;&nbsp;&nbsp;牌：</th>
           	<td>{$sours.brand_name|escape}</td>
           	<td colspan="2" align="center" rowspan="11"><img id="front_image" width="220" height="264" src="{$sours.front_pic}" alt=""></td>
           	<td colspan="2" align="center" rowspan="11"><img id="back_image" width="220" height="264" src="{$sours.back_pic}" alt=""></td>
        </tr>

        <tr>
           	<th  align="right">买&nbsp;&nbsp;&nbsp;&nbsp;手：</th>
           	<td>
               {$sours.buyer_name}
             </td>
           </tr>
           
		   <tr>
            	<th  align="right">跟&nbsp;&nbsp;&nbsp;&nbsp;单：</th>
            	<td>{$sours.merchandiser|escape}</td>
            </tr>
        	<tr>
            	<th  align="right">订&nbsp;单&nbsp;号：</th>
            	<td>{$sours.order_sn|escape}</td>
            </tr>
        	<tr>
            	<th  align="right">款&nbsp;&nbsp;&nbsp;&nbsp;号：</th>
            	<td>{$sours.style_sn|escape}</td>
            </tr>
        	<tr>
            	<th  align="right">参考板号：</th>
            	<td>{$sours.sample_sn|escape}</td>
            </tr>
        	<tr>
            	<th  align="right">到板日期：</th>
            	<td><!-- {if $sours.arrival_date} -->{$sours.arrival_date|date}<!-- {/if} --></td>
            </tr>
        	<tr>
            	<th  align="right">款&nbsp;&nbsp;&nbsp;&nbsp;式：</th>
            	<td>{$sours.style_name|escape}</td>
            </tr>
        	<tr>
            	<th  align="right">工&nbsp;&nbsp;&nbsp;&nbsp;厂：</th>
            	<td>{$sours.factory_name|escape}</td>
            </tr>
        	<tr>
            	<th  align="right">运&nbsp;&nbsp;&nbsp;&nbsp;输：</th>
            	<td><!-- {if $sours.trans_type == 1} -->空运<!-- {else} -->海运<!-- {/if} --></td>
            </tr>
            <tr>
            	<th  align="right">目的地：</th>
            	<td>{$sours.brand_addr|escape}</td>
            </tr>
			<tr>
            	<th  align="right">件&nbsp;&nbsp;&nbsp;&nbsp;数：</th>
            	<td>{$sours.quantity}</td>
            	<td colspan="4" style="text-align:center;">&nbsp;</td>
            </tr>
			<!-- <tr>
            	<th  align="right">工厂价格：</th>
            	<td>{$sours.factory_price}元</td>
				<th  align="right" width="120">工厂入仓日期：</th>
				<td>{if $sours.release_date}{$sours.release_date|date}{/if}</td>
				<th align="right" width="120">实际出货件数：</th>
				<td>{$sours.ship_count}</td>
				</tr>
			<tr>
            	<th  align="right">客人价格：</th>
            	<td>{$sours.customer_price|default:0}&nbsp;{$sours.customer_price_name}</td>
            	<th  align="right">客人入仓日期：</th>
            	<td>{if $sours.buyer_arrival_date}{$sours.buyer_arrival_date|date}{/if}</td>
            	<th  align="right">报&nbsp;价&nbsp;单：</th>
				<td id="factory_files">{foreach from=$file_price item=file}<a href="download.php?id={$file.file_id}">{$file.file_name}</a>{if !$smarty.foreach.last}<br />{/if}--><!--{/foreach}</td>
            	</tr> -->
      <tr>
        <th colspan="1" align="right" style="font-size:12px;">{$lang.fabric_info}：<br></th>
       <td colspan="12" style="margin:0; padding:0;">
       <table width="100%" class="fabric_info_table" cellpadding="0" cellspacing="0">
       <th width="10%" class="no_left_border">成本描述</th>
       <th width="12%">{$lang.fabric_shop_name}</th>
       <th width="8%">品名/货号</th>
       <th width="8%">颜色</th>
       <th width="6%">数量</th>
       <th width="6%" >价格</th>
       <th width="20%">地址</th>
       <th width="12%">电话</th>
       <th width="6%">凭证</th>
       <th width="6%">色卡</th>
       <!-- {if $user.role==USER_MERCHANDISER} -->
       	<!-- {if !$sours.if_print && !$is_view} -->
       		<th width="7%" class="no_right_border">操作</th>
       	<!-- {/if} -->
       <!-- {/if} -->
       <!-- {if !$sours.if_print && !$is_view} -->
       <!-- {if $user.role==USER_MERCHANDISER && $sours.sourcing_status!=SOURCING_STATUS_SAMPLE_CONFIRM && $sours.sourcing_status!=SOURCING_STATUS_FINANCE_EXAMINE} -->
       <tr class="fabric_info_list">
       <td>
       <input name="fabric_info_id[]" type="hidden" value="" />
        <input name="cc_id[]" item="cc_id" type="hidden" value="" />
       <input name="description[]" item="description" type="text"  /></td>
       <td align="left">
       <select style="width:95%; height:20px;"  name="fabric_shop_name[]" item="fabric_shop_name" data-placeholder="请选择" class="chzn-select">
       <option value="0" >未选择</option>
      <!--{foreach from=$fabric_shop_list item=fab_shop_info name=fs}-->
		<option value="{$fab_shop_info.fabric_shop_id}"  >{$fab_shop_info.fabric_shop_name}</option>
       <!--{/foreach}-->
       </select>
       </td>    
       <td><select style="width:80px; height:20px;" name="item[]"  item="item" data-placeholder="未选择" >
        <option value="0" >未选择</option>
       </select></td>
       <td><input name="colors[]" item="colors" type="text"  /></td>
       <td><input name="fabric_num[]" item="fabric_num" type="text"  /></td> 
       <td><input name="price[]" item="price" type="text"  /></td>  
       <td><input name="address[]" item="address" type="text"  /></td>
       <td><input name="phone_mob[]" item="phone_mob" type="text"  /></td>
       <td>
       &nbsp;
       </td>
       <td>
       <a item="picture_show" cid=""  style="display:none;" href="javascript:;">查看</a></td>
       <!-- {if $user.role==USER_MERCHANDISER} -->
       		<td class="no_right_border"><input type="button" item="op" class="btn-2" value="添加" pname="sour_add" /></td>
       <!-- {/if} -->
       </tr>
       <!-- {/if} -->
       <!-- {/if} -->
      <!--{foreach from=$fabric_info_list item=fabric_info name=fi}-->
       <tr class="fabric_info_list">
       <td>
       <input name="fabric_info_id[]" type="hidden" value="{$fabric_info.fabric_info_id}" />
           <input name="cc_id[]" item="cc_id" type="hidden" value="{$fabric_info.cc_id}" />
       <input name="description[]" item="description" type="hidden"  value="{$fabric_info.description|escape}" />{$fabric_info.description|escape}</td>
       <td>
       <input name="fabric_shop_name[]" item="fabric_shop_name" type="hidden"  value="{$fabric_info.fabric_shop_id}" />
{$fabric_info.fabric_shop_name}</td>    
       <td>
       <input name="item[]" item="item" type="hidden"  value="{$fabric_info.item}" />
{$fabric_info.item}
</td>
       <td>
       <input name="colors[]" item="colors" type="<!-- {if $sours.sourcing_status==SOURCING_STATUS_SAMPLE_CONFIRM || $sours.sourcing_status==SOURCING_STATUS_FINANCE_EXAMINE || $sours.if_print || $user.role!=USER_MERCHANDISER || $is_view} -->hidden<!-- {else} -->text<!-- {/if} -->"  value="{$fabric_info.colors}" />
 <!-- {if $sours.sourcing_status==SOURCING_STATUS_SAMPLE_CONFIRM || $sours.sourcing_status==SOURCING_STATUS_FINANCE_EXAMINE || $sours.if_print || $user.role!=USER_MERCHANDISER || $is_view} -->{$fabric_info.colors}<!-- {/if} --></td>
 		<td>
       <input name="fabric_num[]" item="fabric_num" type="<!-- {if $sours.sourcing_status==SOURCING_STATUS_SAMPLE_CONFIRM || $sours.sourcing_status==SOURCING_STATUS_FINANCE_EXAMINE || $sours.if_print || $user.role!=USER_MERCHANDISER || $is_view} -->hidden<!-- {else} -->text<!-- {/if} -->"  value="{$fabric_info.fabric_num}" />
 <!-- {if $sours.sourcing_status==SOURCING_STATUS_SAMPLE_CONFIRM || $sours.sourcing_status==SOURCING_STATUS_FINANCE_EXAMINE || $sours.if_print || $user.role!=USER_MERCHANDISER || $is_view} -->{$fabric_info.fabric_num}<!-- {/if} --></td>
 		<td>
       <input name="price[]" item="price" type="<!-- {if $sours.sourcing_status==SOURCING_STATUS_SAMPLE_CONFIRM || $sours.sourcing_status==SOURCING_STATUS_FINANCE_EXAMINE || $sours.if_print || $is_view} -->hidden<!-- {else} -->text<!-- {/if} -->"  value="{$fabric_info.price}" />
 <!-- {if $sours.sourcing_status==SOURCING_STATUS_SAMPLE_CONFIRM || $sours.sourcing_status==SOURCING_STATUS_FINANCE_EXAMINE || $sours.if_print || $is_view} -->{$fabric_info.price}<!-- {/if} --></td>   
       <td>
        <input name="address[]" item="address" type="<!-- {if $sours.sourcing_status==SOURCING_STATUS_SAMPLE_CONFIRM || $sours.sourcing_status==SOURCING_STATUS_FINANCE_EXAMINE || $sours.if_print || $is_view} -->hidden<!-- {else} -->text<!-- {/if} -->"  value="{$fabric_info.address}" />
		<!-- {if $sours.sourcing_status==SOURCING_STATUS_SAMPLE_CONFIRM || $sours.sourcing_status==SOURCING_STATUS_FINANCE_EXAMINE || $sours.if_print || $is_view} -->{$fabric_info.address}<!-- {/if} --></td>
       <td><input name="phone_mob[]" item="phone_mob" type="<!-- {if $sours.sourcing_status==SOURCING_STATUS_SAMPLE_CONFIRM || $sours.sourcing_status==SOURCING_STATUS_FINANCE_EXAMINE || $sours.if_print || $is_view} -->hidden<!-- {else} -->text<!-- {/if} -->"  value="{$fabric_info.phone_mob}" />
       <!-- {if $sours.sourcing_status==SOURCING_STATUS_SAMPLE_CONFIRM || $sours.sourcing_status==SOURCING_STATUS_FINANCE_EXAMINE || $sours.if_print || $is_view} -->{$fabric_info.phone_mob}<!-- {/if} --></td>
       <td>
       <!-- {if $user.role==USER_SOURCING} -->
      	<a href="{url app=purchase&act=upload_bulk_invoices&s_id=$sours.bulk_id&fid=$fabric_info.fabric_info_id}">上传</a>
      <!-- {else} -->
      	<a href="{url app=purchase&act=upload_bulk_invoices&s_id=$sours.bulk_id&fid=$fabric_info.fabric_info_id}">查看</a>
      <!-- {/if} -->
	</td>
       <td>
      <a  item="picture_show" cid="{$fabric_info.cc_id}"  href="javascript:;">查看</a>
</td>
	<!-- {if $user.role==USER_MERCHANDISER} -->
       	<!-- {if !$sours.if_print && !$is_view} -->
      		<td class="no_right_border"><input type="button" item="op" class="btn-2" value="移除" onClick="remove_fabric_shop(this);"  /></td>
		<!-- {/if} -->
	<!-- {/if} -->
       </tr>
       <!-- {foreachelse} -->
       <tr class="fabric_info_list">
       	<td colspan="10">&nbsp;</td>
       </tr>
       <!--{/foreach}-->
       </table>
       </td>
      </tr>
      <tr>
  		<td>备注:</td>
  		<td colspan="10"><textarea style="width:100%; height:60px;" name="bulk_desction" <!-- {if !($user.role==USER_MERCHANDISER && $sours.bulk_status==BULK_STATUS_CREATE)} -->readonly<!-- {/if} -->>{$sours.bulk_desction}</textarea></td>
  	 </tr>
    </table>
    <!-- {if !$is_view} -->
    <div align="center">
    	<textarea style="width:100%; height:60px; display:none;" id="approve_no_desc"  name="approve_no_desc"></textarea>
    	<!-- {if $user.role==USER_SOURCING} -->
    	<span><input type="button" value="打印" class="btn-2" <!-- {if $user.role==USER_SOURCING} -->onclick="javascript:window.open('{$site_url}/index.php?app=purchase&act=print_bulk&id={$smarty.get.id}');"<!-- {elseif $user.role==USER_MERCHANDISER} -->onclick="s_dayin()"<!-- {/if} --> /></span>&nbsp;&nbsp;
    	<!-- {/if} -->
    	<!-- {if $user.role==USER_SOURCING && ($sours.bulk_status==BULK_STATUS_FINANCE_APPROVE || $sours.bulk_status==BULK_STATUS_CONFIRM)} -->
    	<span><input type="submit" name="submit" value="确认提交" class="btn-2" onClick="if(confirm('确定确认提交该大货采购单吗?提交后将不能再更改！')!=true){return false;}" /></span>&nbsp;&nbsp;
    	<!-- {/if} -->
    	<!-- {if $user.role==USER_FINANCE && ($sours.bulk_status==BULK_STATUS_OUTGOING_CONFIRM || $sours.bulk_status==BULK_STATUS_FINANCE_APPROVE)} -->
    	<span><input type="submit" name="submit" value="审批通过" class="btn-2" onClick="if(confirm('确定审批通过该大货采购单吗?')!=true){return false;}" /></span>&nbsp;&nbsp;
    	<span><input id="sourcing_approve_notpass" onClick="return approve_no()" type="submit" name="submit" value="审批不通过" class="btn-2"/></span>&nbsp;&nbsp;
    	<!-- {/if} -->
    	<!-- {if $user.role==USER_MERCHANDISER_ADMIN && ($sours.bulk_status==BULK_STATUS_SEND_MANAGER || $sours.bulk_status==BULK_STATUS_MANAGER_APPROVE)} -->
    	<span><input type="submit" name="submit" value="审批通过" class="btn-2" onClick="if(confirm('确定审批通过该大货采购单吗?')!=true){return false;}" /></span>&nbsp;&nbsp;
    	<span><input id="sourcing_approve_notpass" onClick="return approve_no()" type="submit" name="submit" value="审批不通过" class="btn-2"/></span>&nbsp;&nbsp;
    	<!-- {/if} -->
    	<!-- {if $user.role==USER_MERCHANDISER && ($sours.bulk_status==BULK_STATUS_SEND_MANAGER || $sours.bulk_status==BULK_STATUS_CREATE)} -->
    	<span><input type="submit" name="submit" value="保存" class="btn-2"/></span>&nbsp;&nbsp;
    	<span><input type="submit" name="submit" value="送主管审批" class="btn-2" onClick="if(confirm('确定把该大货采购单送主管审批吗?')!=true){return false;}" /></span>&nbsp;&nbsp;
    	<!-- {/if} -->
    	<!-- {if $user.role==USER_OUTGOING && $sours.bulk_status==BULK_STATUS_MANAGER_APPROVE} -->
    	<span><input type="submit" name="submit" value="主管确认" class="btn-2" onClick="if(confirm('您确定确认该采购单吗?')!=true){return false;}" /></span>&nbsp;&nbsp;
    	<span><input id="sourcing_approve_notpass" onClick="return approve_no()" type="submit" name="submit" value="退回" class="btn-2"/></span>&nbsp;&nbsp;
    	<!-- {/if} -->
    </div>
    <!-- {/if} -->
	</form>
  </div>
</div>
<script language="javascript" type="text/javascript" src="{res file=js/tab_color.js}"></script>
</body>
</html>